package org.iogame.action;

import com.iohao.game.action.skeleton.annotation.ActionController;
import com.iohao.game.action.skeleton.annotation.ActionMethod;
import com.iohao.game.action.skeleton.core.CmdInfo;
import com.iohao.game.action.skeleton.core.flow.FlowContext;
import com.iohao.game.bolt.broker.core.client.BrokerClientHelper;
import lombok.extern.slf4j.Slf4j;
import org.iogame.annotation.Desc;

/**
 * @author lc
 * @since 2022/10/1
 */
@ActionController(3)
@Slf4j
@Desc(value = "测试模块",longDesc = "这个模块专门用来测试的！")
public class TestAction {
    @ActionMethod(1)
    @Desc(value = "测试1",longDesc = "测试接口1，功能x")
    public UserInfoDto test1(UserInfoDto userInfoDto, FlowContext flowcontext){
        return userInfoDto;
    }

    @ActionMethod(2)
    @Desc(value = "测试2",longDesc = "这是测试接口2，需要登入后使用后，没有参数")
    public UserInfoDto test2(FlowContext flowcontext){
        UserInfoDto dto = new UserInfoDto();
        dto.setNickname("HelloWorld");
        return dto;
    }

    @ActionMethod(3)
    @Desc(value = "测试广播",longDesc = "这是测试广播，没有参数")
    public void test3(FlowContext flowcontext){
        log.info("测试广播");
        UserInfoDto dto = new UserInfoDto();
        dto.setNickname("测试广播");
        // 默认的广播上下文
        var broadcastContext = BrokerClientHelper.me().getBroadcastContext();
        broadcastContext.broadcast(CmdInfo.getCmdInfo(1, 3), dto);
    }
}
